name: Publish site to gh-pages
on:
  push:
    branches:
      - master 
  pull_request:
  
jobs:
  build:
    runs-on: ubuntu-latest
    if: github.ref != 'refs/heads/master'
    steps:
      - name: Checkout main
        uses: actions/checkout@v4
      - name: Build only 
        uses: shalzz/zola-deploy-action@v0.18.0
        env:
          BUILD_ONLY: true
          BUILD_FLAGS: --drafts
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          
  build_and_deploy:
    runs-on: ubuntu-latest
    if: github.ref == 'refs/heads/master'
    steps:
      - name: Checkout main
        uses: actions/checkout@v4
      - name: Build and deploy
        uses: shalzz/zola-deploy-action@v0.18.0
        env:
          PAGES_BRANCH: gh-pages
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
